package chapter04

/**
 * Created with IntelliJ IDEA.
 * ClassName: Test04_9
 * Package: chapter04
 * Description:
 * User: fzykd
 *
 * @Author: LQH
 *          Date: 2023-06-18
 *          Time: 22:01
 */

object Test04_9 {
  def main(args: Array[String]): Unit = {
    //打印输出一个九层妖塔
    for (i <- 1 to 9) {
      //*的个数
      val stars = 2 * i - 1
      //空格的个数
      val spaces = 9 - i
      println(" " * spaces + "*" * stars)
    }

    for (i <- 1 to 9; stars = 2 * i - 1; spaces = 9 - i) {
      println(" " * spaces + "*" * stars)
    }

    for (stars <- 1 to 17 by 2; spaces = (17 - stars) / 2) {
      println(" " * spaces + "*" * stars)
    }




  }
}
